#include "mythread.h"
#include <QMutexLocker>

int myThread:: num=0;
QMutex myThread:: mutex;

myThread::myThread()
{

}

void myThread::run()
{
    for(int i=0;i<10000;i++)
    {
        //访问公共变量加锁
        QMutexLocker locker(&mutex);
        num++;
    }
}
